#include "Tool.h"
#include <windows.h>

CTool::CTool()
{
}


CTool::~CTool()
{
}


void CTool::ReportError(std::string str)
{
    int iError = GetLastError();
    LPVOID lpMessageBuf;
    FormatMessage(
        FORMAT_MESSAGE_ALLOCATE_BUFFER |
        FORMAT_MESSAGE_FROM_SYSTEM |
        FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL,
        iError,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
        (LPTSTR)&lpMessageBuf,
        0,
        NULL
    );

    char cBuffer[MAXBYTE];
    wsprintf(cBuffer, "Error %s:%d-%s\n", str.c_str(), lpMessageBuf);
    MessageBox(NULL, cBuffer, NULL, MB_OK);
}


int CTool::GetLastError()
{
    return WSAGetLastError();
}